<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags"%>
<%@ page isELIgnored="false"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
  <head>
    <link rel="stylesheet" href="<s:url value="/resources"/>/css/innerstyle.css" type="text/css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/cupertino/jquery-ui.custom.min.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/ui.jqgrid.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/ui.multiselect.css" />
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-ui.custom.min.js"></script> 
    <script type="text/javascript" src="<s:url value="/resources"/>/js/i18n/grid.locale-cn.js"></script>    
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery.jqGrid.min.js"></script>
    <script type="text/javascript" src="<s:url value="/resources"/>/js/i18n/jquery.ui.datepicker-zh-CN.js"></script>
  </head>
  <style type="text/css">
    .ui-jqgrid tr.jqgrow td 
	{
		/* jqGrid cell content wrap  */
		white-space: normal !important;
	        height :auto;
	}
	
	th.ui-th-column div
	{
		/* jqGrid columns name wrap  */
		white-space:normal !important;
		height:auto !important;
		padding:0px;
	}
 </style>
  <script type="text/javascript">  
   $(function(){ 
	    $("#chax").button();
	    $("#but_save").button();
	    $("#but_saveFydAndJfd").button(); 
	    $("#but_res").button(); 
	    $("#but_back").button(); 
	    loadTab();    
  });
  
  //加载表
  function loadTab(){ 
      $("#myTab").jqGrid({      
		    url:'<s:url value="/hwjs"/>/findJhtbGrid',   
		    datatype: 'json',
		    mtype: 'post',         
		   	colNames:['选择','铁路计划号', '出卖人','买受人','发货单位','收货单位','发站','到站','吨数','车数','dingdbh,','dingdid','chumdwbm','maisdwbm','fahdwdh','fazhbh','shouhdwdh','daozhbh','pinzbm','pinz','zhilzb','meizbm','meiz'],
		   	colModel:[
		      	{name:'caoz',index:'sysid',width:80,align:"center"}, 
		   		{name:'tieljhh',index:'tieljhh', width:250},
		   		{name:'chumdwmc',index:'chumdwmc', width:500 , sortable:false},
		   		{name:'maisdwmc',index:'maisdwmc', width:500, sortable:false },		
		   		{name:'fahdwmch',index:'fahdwmc', width:500, sortable:false},		
		   		{name:'shouhdwmch',index:'shouhdwmc', width:500, sortable:false},
		   		{name:'fazhmch',index:'fazhmch', width:150, sortable:false},		
		   		{name:'daozh',index:'daozh', width:150, sortable:false},
		   		{name:'huowdsh',index:'huowdsh', sortable:false},
		   		{name:'chesh',index:'chesh', sortable:false},
		   		{name:'dingdid',index:'dingdid',hidden:true}, 
		   		{name:'dingdbh',index:'dingdbh',hidden:true},
				{name:'chumdwbm',index:'chumdwbm',hidden:true},
				{name:'maisdwbm',index:'maisdwbm',hidden:true},
				{name:'fahdwdh',index:'fahdwdh',hidden:true},
				{name:'fazhbh',index:'fazhbh',hidden:true},
				{name:'shouhdwdh',index:'shouhdwdh',hidden:true},
				{name:'daozhbh',index:'daozhbh',hidden:true},
				{name:'pinzbm',index:'pinzbm',hidden:true},
				{name:'pinz',index:'pinz',hidden:true},
				{name:'zhilzb',index:'zhilzb',hidden:true},
				{name:'meizbm',index:'meizbm',hidden:true},
				{name:'meiz',index:'meiz',hidden:true}
		   	],
		    jsonReader: {
		           repeatitems : false, 
		           id: 'sysid'
		         },   
		    height:300, 
		    width:750,	
		   	rowNum:10,
		   	rowList:[10,30,50],     	
		   	pager: '#pager13',
		   	rownumbers: true,   	 
		    viewrecords: true,
		    sortorder: 'desc', 
		    caption: "计划提报列表",
			gridComplete:function()
				{ //在此事件中循环为每一行添加修改和删除链接 	
					var ids=$("#myTab").jqGrid('getDataIDs'); 
					//alert(ids);
					for(var j=0; j<ids.length; j++)
					{		
					     id=ids[j];		    
						 caoz="<a href='#' style='color:#f60' onclick='choose("+ id +")'>选择</a>";
						 $("#myTab").jqGrid('setRowData',id, { caoz: caoz }); 
						
					}
				}		
	       });
	  }
  
	// 查询
	function search(){ 
	  var formdata = $("#form1").serialize(); 
	  $("#myTab").jqGrid('setGridParam',{   
	                          url:'<s:url value="/hwjs"/>/findJhtbGrid?'+formdata,
							  mtype:'post',
							  page:1}).trigger("reloadGrid");  
	}
	
	//选择
	function choose(id) { //选择对应合同
	    var rowData = $("#myTab").jqGrid("getRowData", id);  
	    var parent=window.dialogArguments; 
	    parent.document.getElementById("dingid").value=rowData.dingdid;//计划提报ID
	    parent.document.getElementById("hetbh").value=rowData.dingdbh;
	    parent.document.getElementById("tieljhh").value=rowData.tieljhh;
	    parent.document.getElementById("chumr").value=rowData.chumdwmc;
	    parent.document.getElementById("maishr").value=rowData.maisdwmc;
	    parent.document.getElementById("fahdw").value=rowData.fahdwmch;
	    parent.document.getElementById("shouhdw").value=rowData.shouhdwmch;
	    parent.document.getElementById("fazh").value=rowData.fazhmch;
	    parent.document.getElementById("daozh").value=rowData.daozh;
	    parent.document.getElementById("faydsh").value=rowData.huowdsh;
	    parent.document.getElementById("faychsh").value=rowData.chesh;
	    parent.document.getElementById("chumrid").value=rowData.chumdwbm;
	    parent.document.getElementById("maishrid").value=rowData.maisdwbm;
	    parent.document.getElementById("fahdwid").value=rowData.fahdwdh;
	    parent.document.getElementById("fazhid").value=rowData.fazhbh;
	    parent.document.getElementById("shouhdwid").value=rowData.shouhdwdh;
	    parent.document.getElementById("daozhid").value=rowData.daozhbh;
	    parent.document.getElementById("zhilzhb").value=rowData.zhilzb;
	    //设置煤种默认选中
        var options = parent.document.getElementById("meizhid").options;
		for(var i = 0; i < options.length; i++) {
		        if(options[i].value == rowData.meizbm) {
		                options[i].selected = true;
		        }
		}
	    parent.document.getElementById("meizh").value=rowData.meiz;
	    //设置品名默认选中
	    var options = parent.document.getElementById("pinmid").options;
		for(var i = 0; i < options.length; i++) {
		        if(options[i].value == rowData.pinzbm) {
		                options[i].selected = true;
		        }
		}
	    parent.document.getElementById("pinm").value=rowData.pinz;
	    window.close(); 
	}

</script>  
<body>  
<div id="best1">
<form id="form1" method="post">
<table id="list_search"  style="width:80%"  cellpadding="0" cellspacing="0" border="0"> 
        <tr>
            <td>
            	关键字:
            </td>
            <td>
            	<input type="text" class="longtextbox" name="aa" /> 
            </td>
            <td style="text-align:left">
                <input id="chax" type="button" value="查询" onclick="search();"/>
            </td>
        </tr>
  </table>
  </form>
    <table id="list_search" cellpadding="0" cellspacing="0" border="0">
    </table>
    <table id="myTab" class="scroll" cellpadding="0" cellspacing="0" style="width:50%" ></table>  
   	<div id="pager13" class="scroll"></div>  
   	<div id="message" class="scroll"></div> 
</div> 
</body>
</html>
